#ifndef SWCOMMONWIDGET_H
# define SWCOMMONWIDGET_H

# include <QWidget>
# include <QByteArray>
# include <QFont>
# include <QLineEdit>
# include <QPushButton>
# include <QStatusBar>
# include <QTreeWidget>

/* The server and client share a lot of code because they do a lot of the same
   thing (send and receive data which is logged).
   Rather than duplicate that, this implements what can be shared as protected
   so that both the client and server windows can share code. */
class SWCommonWidget : public QWidget
{
    Q_OBJECT

public:
    SWCommonWidget();

protected:
    QFont m_monospaceFont;
    QTreeWidget *m_eventTree;
    QPushButton *m_outputButton;
    QLineEdit *m_sendLine;
    QStatusBar *m_statusBar;
    int m_wrapOutputAt;
    bool m_isValidEscape;

    QByteArray escapeText(QString);
    QString byteFormat(QByteArray);
    QString textFormat(QByteArray);
    void addEvent(QString, QString, QString);
    void setConnected(bool);

private:
    void addHiddenExpandEvent();
    void createWidgets();
};

#endif
